package com.project.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

@Configuration
@EnableSwagger2
public class SwaggerConfig {
    private ApiInfo getApiInfo(){
        ApiInfo apiInfo = new ApiInfoBuilder()
                .contact(new Contact("成都朗沃信息有限公司",//发布者公司名称
                        "http://localhost:8088",//发布者官网
                        "774205882@qq.com")) //发布者电子邮箱
                .title("进销存管理系统")  //标题
                .description("进销存描述，四位一体") //描述
                .version("1.1")
                .build();
        return apiInfo;
    }

    @Bean
    public Docket createRestApi() {
        return new Docket(DocumentationType.SWAGGER_2)
                .apiInfo(getApiInfo()) //api文档的详细信息
                .select() //初始化并返回一个API选择构造器
                .paths(PathSelectors.any()) //设置路径筛选
                .apis(RequestHandlerSelectors.basePackage(
                        "com.project.controller"))// 添加路径选择条件
                .build();
    }
}
